package edu.Pta;

import java.util.*;

abstract class Animal{
    String name;
    String age;
    public String getName() {
        return name;
    }
    public void setName(String name) {
        this.name = name;
    }
    public String getAge() {
        return age;
    }
    public void setAge(String age) {
        this.age = age;
    }
    @Override
    public String toString() {
        return "Animal [name=" + name + ", age=" + age + "]";
    }
    public String play() {
        return "Animal";
    }

}

class Bird extends Animal{
    public Bird(){}
    public Bird(String s1,String s2) {
        name=s1;
        age=s2;
    }

    @Override
    public String toString() {
        return "Bird[name=" + name + ", age=" + age + "]";
    }
    public String play() {
        return "Bird";
    }
}

class Dog extends Animal{
    String leg;
    public Dog(String s1,String s2,String s3) {
        name=s1;
        age=s2;
        leg=s3;
    }
    public String getLeg() {
        return leg;
    }
    public void setLeg(String leg) {
        this.leg = leg;
    }
    @Override
    public String toString() {
        return "Dog[leg=" + leg + ", name=" + name + ", age=" + age + "]";
    }
    public String play() {
        return "Dog";
    }
}

public class AnimalList {
    public static void main(String[] args) {
        // TODO Auto-generated method stub
        Scanner sc = new Scanner(System.in);
        int n=sc.nextInt();
        String s1,s2,s3;
        LinkedList<Animal> lk=new LinkedList<Animal>();
        for(int i=0;i<n;i++) {
            int k=sc.nextInt();
            if(k==1) {
                s1=sc.next();
                s2=sc.next();
                s3=sc.next();
                Dog d=new Dog(s1,s2,s3);
                lk.add(d);
            }else {
                s1=sc.next();
                s2=sc.next();
                Bird d=new Bird(s1,s2);
                lk.add(d);
            }
        }

        System.out.printf("[");
        for(int i=0;i<n;i++) {
            if(i==0) {
                System.out.printf(lk.get(i).toString());
            }else
            {
                System.out.printf(", "+lk.get(i).toString());
            }

        }
        System.out.println("]");
        int i;
        s1=sc.next();
        for(i=0;i<n;i++) {
            // System.out.println(lk.get(i).getName().length());
            // System.out.println(s1.length());
            if(s1.equals(lk.get(i).getName())) {
                System.out.println(lk.get(i).play());
                System.out.printf(lk.get(i).toString());
                break;
            }
        }
        if(i==n) {
            System.out.print("no this one");
        }
    }

}

